<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>top</title>
    <link rel="stylesheet" href="./css/top.css" type="text/css">
</head>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<script src="/js/config.js"></script>
<body onload="save()">
<div id="top">
    <div id="l_r">
        <a href="register.html"class="lr1" target="_parent">注册</a>
        <a href="login.html" class="lr1" target="_parent">登录</a>
        <a class="lr2" id="userInfo" style="display: none"></a><a href="/returnLogin" class="lr2" style="display: none">退出</a>
    </div>
</div>
<script type="text/javascript">
    function save()
    {
        var url = host + '/session';
        $.ajax(url, {
            dataType: 'text',
            crossDomain: true,
            success: function(data) {
                if(data == null || data == ""){
                    return;
                }
                $("#userInfo").text(data);
                var lr1s = $(".lr1");
                for(var i = 0; i<lr1s.length; i++){
                    lr1s[i].style.display = "none";
                }
                var lr2s = $(".lr2");
                for(var i = 0; i<lr2s.length; i++){
                    lr2s[i].style.display = "block";
                }
            },
            error : function() {
                alert('error...');
            }
        })}
</script>
</body>
</html>